webpackJsonp([2],{

/***/ 48:
/***/ (function(module, exports, __webpack_require__) {

module.exports = __webpack_require__(49);


/***/ }),

/***/ 49:
/***/ (function(module, exports, __webpack_require__) {


/**
 * First we will load all of this project's JavaScript dependencies which
 * includes Vue and other libraries. It is a great starting point when
 * building robust, powerful web applications using Vue and Laravel.
 */

__webpack_require__(6);

/**
 * Next, we will create a fresh Vue application instance and attach it to
 * the page. Then, you may begin adding components to this application
 * or customize the JavaScript scaffolding to fit your unique needs.
 */

__webpack_require__(7);

$(document).ready(function () {
    //可嵌套列表
    // activate Nestable for list
    $('#nestable').nestable({
        group: 1
    }).on('change', function (e) {
        var list = e.length ? e : $(e.target),
            output = list.data('output');
        $.ajax({
            type: "post",
            headers: {
                'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
            },
            url: saveSortUrl,
            data: {
                'sortData': list.nestable('serialize')
            },
            datatype: "json",
            success: function success(data) {
                showToastr(data);
            }
        });
    });

    $('#nestable-menu').on('click', function (e) {
        var target = $(e.target),
            action = target.data('action');
        if (action === 'expand-all') {
            $('.dd').nestable('expandAll');
        }
        if (action === 'collapse-all') {
            $('.dd').nestable('collapseAll');
        }
    });
    //表单验证
    $("#form").validate({
        rules: {
            name: {
                required: true
            }
        },
        submitHandler: function submitHandler(form) {
            $(form).ajaxSubmit({
                type: 'post',
                dataType: 'json',
                success: function success(data) {
                    showToastr(data, 'go');
                }
            });
        }
    });
    //载入树结构select的option的html
    function loadOption() {
        var secId = arguments[0] ? arguments[0] : 0;
        $.ajax({
            type: "get",
            url: treeOptionUrl,
            data: {
                'secId': secId,
                'listType': 'all'
            },
            success: function success(data) {
                $("#form select[name='parent_id']").html(data);
            }
        });
    }
    //弹窗
    $(".add").on('click', function () {
        $(".modal-title").html('添加角色');
        //加载选择项
        loadOption();
        $("#form")[0].reset();
        $("#form input[name='role_id']").val(0);
    });
    $(".addchild").on('click', function () {
        $(".modal-title").html('添加角色');
        $("#form")[0].reset();
        $("#form input[name='role_id']").val(0);
        //加载父级菜单选择项
        loadOption($(this).parents("li").attr('data-id'));
    });
    $(".edit").on('click', function () {
        $(".modal-title").html('编辑角色');
        //加载选择项
        loadOption();
        $.ajax({
            type: "get",
            url: getUrl,
            data: {
                'id': $(this).parents("li").attr('data-id')
            },
            datatype: "json",
            success: function success(data) {
                $("#form input[name='role_id']").val(data.data.role_id);
                $("#form input[name='name']").val(data.data.name);
                $("#form input[name='display_name']").val(data.data.display_name);
                $("#form select[name='parent_id']").val(data.data.parent_id);
                $("#form textarea[name='description']").val(data.data.description);
            }
        });
    });
    $(".del").on('click', function () {
        var id = $(this).parents("li").attr('data-id');
        myConfirm(delUrl, { 'id': id });
    });
    //编辑权限,参考网址(http://luozhihua.com/jquery-jstree%E9%80%89%E4%B8%AD%E6%88%96%E5%8F%96%E6%B6%88%E9%80%89%E4%B8%AD%E8%8A%82%E7%82%B9.html)
    $('.editperm').on('click', function () {
        var id = $(this).parents("li").attr('data-id');
        redirect(editpermUrl + "?roleId=" + id);
    });
});

/***/ }),

/***/ 6:
/***/ (function(module, exports, __webpack_require__) {


window._ = __webpack_require__(1);

/**
 * We'll load jQuery and the Bootstrap jQuery plugin which provides support
 * for JavaScript based Bootstrap features such as modals and tabs. This
 * code may be modified to fit the specific needs of your application.
 */

/*
try {
    window.$ = window.jQuery = require('jquery');

    require('bootstrap-sass');
} catch (e) {}
*/

/**
 * We'll load the axios HTTP library which allows us to easily issue requests
 * to our Laravel back-end. This library automatically handles sending the
 * CSRF token as a header based on the value of the "XSRF" token cookie.
 */

window.axios = __webpack_require__(2);

window.axios.defaults.headers.common['X-Requested-With'] = 'XMLHttpRequest';

/**
 * Next we will register the CSRF Token as a common header with Axios so that
 * all outgoing HTTP requests automatically have it attached. This is just
 * a simple convenience so we don't have to attach every token manually.
 */

var token = document.head.querySelector('meta[name="csrf-token"]');

if (token) {
  window.axios.defaults.headers.common['X-CSRF-TOKEN'] = token.content;
} else {
  console.error('CSRF token not found: https://laravel.com/docs/csrf#csrf-x-csrf-token');
}

/**
 * Echo exposes an expressive API for subscribing to channels and listening
 * for events that are broadcast by Laravel. Echo and event broadcasting
 * allows your team to easily build robust real-time web applications.
 */

// import Echo from 'laravel-echo'

// window.Pusher = require('pusher-js');

// window.Echo = new Echo({
//     broadcaster: 'pusher',
//     key: 'your-pusher-key'
// });

/***/ }),

/***/ 7:
/***/ (function(module, exports) {

var _arguments = arguments,
    _this2 = this;

//设置toastr选项
toastr.options = {
    "closeButton": true,
    "debug": false,
    "progressBar": true,
    "preventDuplicates": false,
    "positionClass": "toast-top-right",
    "onclick": null,
    "showDuration": "400",
    "hideDuration": "1000",
    "timeOut": "1000",
    "extendedTimeOut": "1000",
    "showEasing": "swing",
    "hideEasing": "linear",
    "showMethod": "fadeIn",
    "hideMethod": "fadeOut"
};
window.utils = {
    /**
     *
     * @param data json响应数据
     * @param loadtag 载入标签
     */
    showToastr: function showToastr(data) {
        var loadtag = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '';

        loadtag = _arguments[1] ? _arguments[1] : false;
        switch (data.status) {
            case 'success':
                toastr.success(data.message, data.title);
                break;
            case 'error':
                toastr.error(data.message, data.title);
                break;
            case 'info':
                toastr.info(data.message, data.title);
                break;
            default:
                toastr.warning(data.message, data.title);
                break;
        }
        if (data.status == 'success') {
            switch (loadtag) {
                case 'reload':
                    _this2.reload(data.jumpTime);
                    break;
                case 'goback':
                    _this2.goback(data.jumpTime);
                    break;
                case 'go':
                    if (data.url) {
                        _this2.redirect(data.url, data.jumpTime);
                    }
                    break;
                default:
                    break;
            }
        }
    },
    /**
     * 确认框
     * @param url
     * @param data
     * @param title
     * @param content
     */
    confirm: function confirm(url) {
        var data = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
        var title = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : '你确定删除么？';
        var content = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : '删除后将无法恢复';

        var _this = window.utils;
        $.confirm({
            title: title,
            content: content,
            buttons: {
                '确定': function _() {
                    axios.post(url, data).then(function (response) {
                        _this.showToastr(response, 'go');
                    }).catch(function (error) {
                        _this.showToastr({ 'status': 'error', 'title': '请求错误', 'message': error });
                    });
                },
                '取消': function _() {}
            }
        });
    },
    /**
     * 页面跳转，重定向
     * @param url 跳转链接
     * @param times 等待时间
     */
    redirect: function redirect(url) {
        var times = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 1000;

        if (times > 0) {
            setTimeout(function () {
                window.location.href = url;
            }, times);
        } else {
            window.location.href = url;
        }
    },
    /**
     * 页面刷新
     * @param times 等待时间
     */
    reload: function reload() {
        var times = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 1000;

        if (times) {
            setTimeout(function () {
                window.location.reload();
            }, times);
        } else {
            window.location.reload();
        }
    },
    /**
     * 页面返回
     * @param times 等待时间
     */
    goback: function goback() {
        var times = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 1000;

        if (times) {
            setTimeout(function () {
                window.history.back(-1);
            }, times);
        } else {
            window.history.back(-1);
        }
    }
};

/***/ })

},[48]);